﻿using UnityEngine;
using UnityEditor;
using System;
using System.Collections;

using Hont;

namespace Hont.UMotionGraph
{
    [CustomEditor(typeof(MGSoundEffector), true)]
    public class MGSoundEffectorInspector : Editor
    {
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            var target = base.target as MGSoundEffector;
            if (target.soundSampleArr == null) return;

            var rect = GUILayoutUtility.GetLastRect();

            rect.y += 25;
            rect.height = 80 - 25;

            GUI.Box(rect, "");
            var num = target.soundSampleArr.Length;
            for (int i = 0; i < num; i++)
            {
                var width = rect.width / num;
                var height = target.soundSampleArr[i] * 150f;
                var heightSub = rect.height - height;
                GUI.Box(new Rect(rect.x + i * width, rect.y + heightSub, width, height), "");
            }

            GUILayout.Space(80);
        }

        void Awake()
        {

        }
    }
}
